﻿ 

using System;
using System.Collections.Generic;
using System.ServiceModel;
using System.Reflection;
using zkdao.Application;
using zkdao.Domain;
using sharp_net;
using log4net;

namespace zkdao.Wcf {
	public class UserService : IUserService {
		private readonly IUserService userService = IocLocator.Instance.GetImple<IUserService>();
				public UserData GetByID(Guid ID) {
			try {
				return userService.GetByID(ID);
			}
			catch(Exception ex) {
				ILog Log = LogManager.GetLogger("AppService", MethodBase.GetCurrentMethod().DeclaringType);
				Log.Error(ex);
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
				public UserData GetByKey(String userkey) {
			try {
				return userService.GetByKey(userkey);
			}
			catch(Exception ex) {
				ILog Log = LogManager.GetLogger("AppService", MethodBase.GetCurrentMethod().DeclaringType);
				Log.Error(ex);
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
				public Int32 GetCount() {
			try {
				return userService.GetCount();
			}
			catch(Exception ex) {
				ILog Log = LogManager.GetLogger("AppService", MethodBase.GetCurrentMethod().DeclaringType);
				Log.Error(ex);
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
				public IEnumerable<UserData> GetPager(Int32 pageIndex, Int32 pageSize) {
			try {
				return userService.GetPager(pageIndex, pageSize);
			}
			catch(Exception ex) {
				ILog Log = LogManager.GetLogger("AppService", MethodBase.GetCurrentMethod().DeclaringType);
				Log.Error(ex);
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
				public UserData Register(UserData dataObject) {
			try {
				return userService.Register(dataObject);
			}
			catch(Exception ex) {
				ILog Log = LogManager.GetLogger("AppService", MethodBase.GetCurrentMethod().DeclaringType);
				Log.Error(ex);
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
				public Boolean Approved(String userkey, String approvedID) {
			try {
				return userService.Approved(userkey, approvedID);
			}
			catch(Exception ex) {
				ILog Log = LogManager.GetLogger("AppService", MethodBase.GetCurrentMethod().DeclaringType);
				Log.Error(ex);
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
				public void RequestApproved(String userkey) {
			try {
				 userService.RequestApproved(userkey);
			}
			catch(Exception ex) {
				ILog Log = LogManager.GetLogger("AppService", MethodBase.GetCurrentMethod().DeclaringType);
				Log.Error(ex);
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
				public Boolean Validate(String userkey, String password) {
			try {
				return userService.Validate(userkey, password);
			}
			catch(Exception ex) {
				ILog Log = LogManager.GetLogger("AppService", MethodBase.GetCurrentMethod().DeclaringType);
				Log.Error(ex);
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
				public void Update(String userkey, UserData dataObject) {
			try {
				 userService.Update(userkey, dataObject);
			}
			catch(Exception ex) {
				ILog Log = LogManager.GetLogger("AppService", MethodBase.GetCurrentMethod().DeclaringType);
				Log.Error(ex);
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
			}
}